import {
    buildingList,
    buildingPage,
    buildingAdd,
    buildingUpdate,
    buildingDelete
} from '@/api/base.building'
export default {
    namespaced: true,
    //数据保存在State中
    state: {
        menu: []
    },
    //对于后台的请求放在actions中
    actions: {
        getBuildingList() {
            return new Promise((resolve, reject) => {
                buildingList().then(
                    res => {
                        resolve(res)
                    }
                )
            })
        },
        //context 对象是vuex框架自己放入到第一个参数,界面上调用时传入的参数,需要放入第二个参数
        getBuildingPage(context, data) {
            return new Promise((resolve, reject) => {
                buildingPage(data).then(
                    res => {
                        resolve(res)
                    }
                )
            })
        },
        addbuilding(context, data) {
            return new Promise((resolve, reject) => {
                console.log('addbuilding')
                console.log(data)
                buildingAdd(data).then(
                    resolve()
                )
            })
        },

        updatebuilding(context, data) {
            return new Promise((resolve, reject) => {
                console.log('updatebuilding')
                console.log(data)
                buildingUpdate(data).then(
                    resolve()
                )
            })
        },

        deletebuilding(context, id) {
            return new Promise((resolve, reject) => {
                buildingDelete(id).then(
                    resolve()
                )
            })
        }
    }
}